package com.example.jetpackcompose

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
import androidx.compose.material1.Slider
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.jetpackcompose.ui.theme.JetpackComposeTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val min = 0f
        val max = 1f

        setContent {
            JetpackComposeTheme {
                // A surface container using the 'background' color from the theme
                Row {
                    var sliderPosition by remember { mutableStateOf(0.5f) }
                    repeat(4) {
                        Column(
                            modifier = Modifier.weight(1f)
                        ) {
                            for (i in 1..25) {
                                Row(verticalAlignment = Alignment.CenterVertically) {
                                    Text(text = (sliderPosition * 100).toInt().toString(), Modifier.width(30.dp))
                                    Slider(
                                        valueRange = (min..max), value = sliderPosition, modifier = Modifier
                                            .height(25.dp), onValueChange = { sliderPosition = it })
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String) {
    Text(text = "Hello $name!")
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    JetpackComposeTheme {
        Greeting("Android")
    }
}